<?php
$db = Db::getInstance();
$id = Authenticate::getId();
$query = "SELECT
    (SELECT COUNT(*) FROM Invoice WHERE accountId='{$id}' AND DATE(dateDue)>=NOW() AND status='0') AS cInvoice,
    (SELECT COUNT(*) FROM Product WHERE accountId='{$id}') AS cProduct,
    (SELECT COUNT(*) FROM Topic WHERE accountID='{$id}' AND readNew='1') AS cTopic
";
$result = $db->query($query);
if(!$result){
	echo $db->error;
}
$arr = $result->fetch_assoc();
?>
<style type="text/css">
.menu-user .nav-pills>li>a {
	padding-top: 0;
	padding-bottom: 0;
}
.menu-user .nav-pills>.active>a, .menu-user .nav-pills>.active>a:hover {
	background: #a6ecb0;
}
</style>
<div class="span3 pull-left menu-user">
	<ul class="nav nav-pills nav-stacked">
		<!-- 
		<li class="<?php if($_GET['page']=='user/index') echo 'active'; ?>">
			<a href="index.php?page=user/index">มุมสำหรับสมาชิก</a>
		</li>
		 -->
		<li class="<?php if($_GET['page']=='user/profile') echo 'active'; ?>">
            <a href="index.php?page=user/profile"><img src="images/user/icon-menu-01.png" />ข้อมูลส่วนตัว</a>
        </li>
        <!--
		<li class="<?php if($_GET['page']=='user/invoice') echo 'active'; ?>">
			<a href="index.php?page=user/invoice">
				<img src="images/user/icon-menu-02.png" />
				ใบเรียกเก็บเงิน
				<?php if($arr['cInvoice'] != 0){?><span class="badge badge-important"><?php echo $arr['cInvoice'];?></span><?php }?>
			</a>
		</li>
		-->
		<li class="<?php if($_GET['page']=='user/product') echo 'active'; ?>">
			<a href="index.php?page=user/product">
				<img src="images/user/icon-menu-03.png" />
				บริการของฉัน
                <?php if($arr['cInvoice'] != 0){?><span class="badge badge-important"><?php echo $arr['cInvoice'];?></span><?php }?>
			</a>
		</li>
		<li class="<?php if($_GET['page']=='user/articles') echo 'active'; ?>">
			<a href="index.php?page=user/articles"><img src="images/user/icon-menu-04.png" />บทความ</a>
		</li>
		<li class="<?php if($_GET['page']=='user/recommend.payment') echo 'active'; ?>">
			<a href="index.php?page=user/recommend.payment">
				<img src="images/user/icon-menu-06.png" />วิธีการชำระเงิน
			</a>
		</li>
		<li class="<?php if($_GET['page']=='user/qa') echo 'active'; ?>">
			<a href="index.php?page=user/qa">
				<img src="images/user/icon-menu-07.png" />คำถาม
                <?php if($arr['cTopic'] != 0){?><span class="badge badge-info"><?php echo $arr['cTopic'];?></span><?php }?>
			</a>
		</li>
	</ul>
	<ul class="nav nav-pills nav-stacked">
		<li class="<?php if($_GET['page']=='user/logout') echo 'active'; ?>"><a href="index.php?page=logout">
		<img src="images/user/icon-menu-08.png" />ออกจากระบบ</a></li>
	</ul>
</div>